Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orientation fix for mobile #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bagshik
Copy link

@bagshik bagshik commented Oct 6, 2018

Description

Game didn't work on mobile devices, this is one way to fix it. Feedback is welcome :)

Fixes #37

Checklist:

  • I'm already part of the contributors list. Don't know how to add yourself? You can use this tool.
  • Tests are included.

@codecov
Copy link

codecov bot commented Oct 6, 2018

Codecov Report

Merging #38 into master will decrease coverage by 0.87%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #38      +/-   ##
==========================================
- Coverage     100%   99.12%   -0.88%     
==========================================
  Files          10       10              
  Lines         108      114       +6     
  Branches       19       22       +3     
==========================================
+ Hits          108      113       +5     
- Partials        0        1       +1
Impacted Files Coverage Δ
src/containers/Orientation.js 92.85% <87.5%> (-7.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8414978...b00ca4c. Read the comment docs.

Copy link
Owner

@Wgil Wgil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for helping with the project. I added some comments that need to be solved before merging the pull request. Please, don't forget to add yourself to the contributor's list and so fix the tests to recover the coverage.

if (isMobileDevice()) {
return isLandscape() ? "landscape-primary" : "portrait";
} else {
return window.screen.orientation.type;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should replace window.screen.orientation with something else since it's not fully supported yet by all browsers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, will look into this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,16 +1,29 @@
import React, { Component } from "react";
import PropTypes from "prop-types";

const isMobileDevice = () =>
typeof window.orientation !== "undefined" ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that window.orientation is not going to be our best friend since it's deprecated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow I wasn't aware of this, I'll look for an alternative approach 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should re-think the solution because the device orientation stuff is kind of experimental. Basically, the idea behind the feature is to prevent the game to be rendered in small screens. We can simply do that based on the screen width and use the resize event to swap components as we currently do with the Orientation component. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 makes sense, I can make those changes. Do you have a minimum width in mind?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's show the Game component at minimum 542px width. Below we can just show the RotateInfo component. Please, remember to listen to the resize event and also perform the check on mounting phase. Test your code and include yourself into the contributor's list :) Thanks again for the collaboration!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any advance on this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo, I had a lot going on at work 😅 I'm almost done, will definitely push this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants